package com.fling.services;

import com.badlogic.gdx.Preferences;
import com.fling.Constants;
import com.fling.Locator;

public class AccomplishmentsOutbox implements Constants {
	private Achievements achvs;
	int distance = 0;

	public AccomplishmentsOutbox(Achievements achvs) {
		this.achvs = achvs;
	}

	boolean isEmpty() {
		return true;
	}

	public void saveLocal(Preferences prefs, int dist) {
		prefs.putBoolean("hoarder", achvs.isHoarder());
		prefs.putBoolean("bigClimber", achvs.isBigClimber());
		prefs.putBoolean("averageClimber", achvs.isAverageClimber());
		prefs.putBoolean("smallClimber", achvs.isSmallClimber());
		prefs.putBoolean("hardcore", achvs.isHardcore());
		distance = dist;

	}

	public void loadLocal(Preferences prefs, int dist) {
		achvs.setHoarder(prefs.getBoolean("hoarder"));
		achvs.setBigClimber(prefs.getBoolean("bigClimber"));
		achvs.setAverageClimber(prefs.getBoolean("averageClimber"));
		achvs.setSmallClimber(prefs.getBoolean("smallClimber"));
		achvs.setHardcore(prefs.getBoolean("hardcore"));
		distance = dist;
	}

	public void pushAccomplishments() {
		if (achvs.isHoarder()) {
			achvs.unlock(ACHV_HOARDER);
		}
		if (achvs.isBigClimber()) {
			achvs.unlock(ACHV_BIG_CLIMBER);
		}
		if (achvs.isAverageClimber()) {
			achvs.unlock(ACHV_AVERAGE_CLIMBER);
		}
		if (achvs.isSmallClimber()) {
			achvs.unlock(ACHV_SMALL_CLIMBER);
		}
		if (achvs.isHardcore()) {
			achvs.unlock(ACHV_HARDCORE);
		}
		if(distance > 0){
			Locator.getDevice().submitLeaderboardScore(distance);
		}
	}
}